import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPTransformServer {
    public static void main(String[] args) {
        try {
            ServerSocket serverSocket = new ServerSocket(8888);
            Socket server = serverSocket.accept();

            InputStream inputStream = server.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

            OutputStream outputStream = server.getOutputStream();
            OutputStreamWriter outputStreamWriter = new OutputStreamWriter(outputStream);
            BufferedWriter bufferedWriter = new BufferedWriter(outputStreamWriter);

            String line = bufferedReader.readLine();
            System.out.println("从客户单接收字符串：" + line);
            String upperCase = line.toUpperCase();
            bufferedWriter.write(upperCase);
            bufferedWriter.write("\r\n");
            bufferedWriter.flush();

            bufferedWriter.close();
            outputStreamWriter.close();
            outputStream.close();
            bufferedReader.close();
            inputStreamReader.close();
            inputStream.close();
            server.close();
            serverSocket.close();

        } catch (IOException e) {


        }

    }
}
